{% import '@SyliusAdmin/Common/Macro/money.html.twig' as money %}
{% import '@SyliusUi/Macro/buttons.html.twig' as buttons %}

{% if credit_memos|length > 0 %}
<div class="ui segment" id="credit-memos">
    <h3 class="ui dividing header">{{ 'sylius_refund.ui.credit_memos'|trans }}</h3>
    <table class="ui celled compact small table fixed">
        <thead>
            <tr>
                <th>{{ 'sylius.ui.number'|trans }}</th>
                <th>{{ 'sylius.ui.channel'|trans }}</th>
                <th>{{ 'sylius.ui.total'|trans }}</th>
                <th>{{ 'sylius_refund.ui.issued_at'|trans }}</th>
                <th class="six wide">{{ 'sylius.ui.actions'|trans }}</th>
            </tr>
        </thead>
        <tbody>
        {% for credit_memo in credit_memos %}
            <tr>
                <td>{{ credit_memo.number }}</td>
                <td>{% include '@SyliusAdmin/Common/_channel.html.twig' with {'channel': credit_memo.channel} %}</td>
                <td>{{ money.format(credit_memo.total, credit_memo.currencyCode) }}</td>
                <td>{{ credit_memo.issuedAt|date('d-m-Y') }}</td>
                <td>
                    <div class="ui buttons">
                        {{ buttons.default(
                            path('sylius_refund_credit_memo_details', {'orderNumber': credit_memo.order.number, 'id': credit_memo.id}),
                            'sylius.ui.details',
                            null,
                            'eye'
                        ) }}
                        {{ buttons.default(
                            path('sylius_refund_admin_credit_memo_download', {'id': credit_memo.id}),
                            'sylius_refund.ui.download',
                            null,
                            'download',
                            'blue'
                        ) }}
                    </div>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
</div>
{% endif %}
